package com.yndsoft.jc.supplier.adapter;

import android.content.Context;
import android.view.View;

import com.yndsoft.jc.R;
import com.yndsoft.jc.supplier.model.CategoryModel;
import com.yndsoft.jc.supplier.perfect.OnChooseCategoryListener1;
import com.yndsoft.jc.supplier.widget.recyclerview.RecyclerAdapter;
import com.yndsoft.jc.supplier.widget.recyclerview.RecyclerHolder;
import com.yndsoft.jc.supplier.widget.recyclerview.RecyclerListener;

import java.util.List;

public class CategoryAdapter1 extends RecyclerAdapter<CategoryModel> implements RecyclerListener.OnClickListener<RecyclerHolder> {

    private OnChooseCategoryListener1 listener;

    public void setOnChooseCategoryListener1(OnChooseCategoryListener1 listener) {
        this.listener = listener;
    }

    public CategoryAdapter1(Context context, List<CategoryModel> data) {
        super(context, data, R.layout.item_category);
    }

    @Override
    public void convert(RecyclerHolder holder, CategoryModel model) {
        holder.setTvText(R.id.category, model.getName());
        holder.setOnClickListener(this, R.id.category);
    }

    @Override
    public void onClick(View v, int position, RecyclerHolder holder) {
        if (listener != null) {
            listener.onChooseCategory1(mData.get(position));
        }
    }
}
